import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  state: () => ({
    token: '',
    role: 'user',  // 或 'admin'
    userInfo: null as null | { id: number, name: string }
  }),
  actions: {
    setToken(token: string) {
      this.token = token
    },
    setUserInfo(info: any) {
      this.userInfo = info
    },
    setRole(role: string) {
      this.role = role
    }
  }
})
